package com.mastercard.labs

class TransactionService {

	def serviceMethod() {
	}

	/**
	 * Return transaction details for
	 * spending history
	 * @param fromDate
	 * @param toDate
	 * @return
	 */
	def getTransactions(Date fromDate, Date toDate) {
		def transactions = Transaction.findAllByTxnDateBetween(fromDate, toDate, [sort: "txnDate", order: "desc"])
		return transactions
	}


	/**
	 * Retrieve total spending for last 12 months
	 * Total spending should be break into each individual card
	 * @param fromDate
	 * @param toDate
	 * @return
	 */
	def getTotalSpending(Date fromDate, Date toDate) {
		def transactions = getTransactions(fromDate, toDate)

		// Loop through the month fromDate -> toDate

		// Add the total spending for the transaction if
		// it is in this month

		// Return array list
	}

	/**
	 * Retrieve monthly spending, 
	 * break into categories, and card
	 * @param fromDate
	 * @param toDate
	 * @return
	 */
	def getCategorySpending(Date fromDate, Date toDate) {
		def transactions = getTransactions(fromDate, toDate)
		// Loop through the month fromDate -> toDate

		// Add the monthly spending for the category of transaction if
		// it is in this month

		// Return array list
	}
}
